package com.sikaryofficial.adaptermq.message.consumer;

import com.sikaryofficial.adaptermq.message.body.SyncDataMessage;
import com.sikaryofficial.adaptermq.service.ISyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class SyncConsumerProcess {

    @Autowired
    private  ISyncService syncService;

    /**
     * 消息监听
     * <p>
     * 基于所有canal 生产数据，进行消费
     * 所有同步表监听
     *
     * @param message 消息
     */
    @StreamListener(MQConsumer.CANAL_DATA_SYNC_INPUT)
    public void onAllTableMessage(@Payload SyncDataMessage message) {
        syncService.processData(message);
    }
}
